
#include "GiftSenderProxy.h"

using namespace npProxy;


//other constructors
GiftSenderProxy::GiftSenderProxy(weak_ptr<GiftSender> giftSender)
{
    this->giftSender = giftSender;
}

//public methods
void GiftSenderProxy::sendDolls() throw(GiftSender::ErrorEnum, ErrorEnum)
{
    // 抛出不同的枚举异常测试
    // throw ErrorEnum::NoGiftSenderToProxyException;

    if (shared_ptr<GiftSender> gs = this->giftSender.lock())
    {
        try
        {
            gs->sendDolls();
        }
        catch(const GiftSender::ErrorEnum& e)
        {
            throw e;
        }
        
    }
    else
    {
        throw ErrorEnum::NoGiftSenderToProxyException;
    }
}

void GiftSenderProxy::sendFollows() throw(GiftSender::ErrorEnum, ErrorEnum)
{
    if (shared_ptr<GiftSender> gs = this->giftSender.lock())
    {
        try
        {
            gs->sendFollows();
        }
        catch(const GiftSender::ErrorEnum& e)
        {
            throw e;
        }
        
    }
    else
    {
        throw ErrorEnum::NoGiftSenderToProxyException;
    }
}

void GiftSenderProxy::sendChocolates() throw(GiftSender::ErrorEnum, ErrorEnum)
{
    if (shared_ptr<GiftSender> gs = this->giftSender.lock())
    {
        try
        {
            gs->sendChocolates();
        }
        catch(const GiftSender::ErrorEnum& e)
        {
            throw e;
        }
        
    }
    else
    {
        throw ErrorEnum::NoGiftSenderToProxyException;
    }
    
}

//protected methods

//private methods

//static part

//others
